#include <cstdint>
#include <iostream>

/**
 * @brief 强枚举类型
 */
enum class EPermission : uint8_t
{
    eRead = 0x01,   // 0000 0001
    eWrite = 0x02,  // 0000 0010
    eExec = 0x04    // 0000 0100
};

/**
 * @brief 枚举或运算
 * @param lhs 左边枚举值
 * @param rhs 右边枚举值
 * @return 枚举值
 */
inline EPermission operator | (EPermission lhs , EPermission rhs)
{
    using T = std::underlying_type_t<EPermission> ; // 获取枚举底层类型
    return static_cast<EPermission>(static_cast<T> (lhs) | static_cast<T> (rhs));
}

inline bool bPermission(EPermission eValue , EPermission flag)
{
    using T = std::underlying_type_t<EPermission>;
    return (static_cast<T>(eValue) & static_cast<T>(flag)) != 0;
}

int main()
{
    EPermission ep = EPermission::eRead | EPermission::eWrite;

    if (bPermission(ep , EPermission::eRead))
    {
        std::cout << "Read" << std::endl;
    }

}